﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Vds2465Telegrams
{
	[TestClass]
	public class UserData_74_Container_Test
	{
		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test01_Equals()
		{
			byte[] bytes = new byte[] { 0x55, 0x66, 0xaa, 0x00, 0xff };
			UserData_74_Container userData = new UserData_74_Container(0x99, (byte) (eBusType.EIBus), bytes);

			{
				// completely different type - NOT equal
				object dummyObject = new object();
				Assert.IsFalse(userData.Equals(dummyObject));
			}

			{
				// different derived type 
				UserData_11_Error userData2Compare = new UserData_11_Error(eErrorCode.DataOutOfRange, 0x99);
				Assert.IsFalse(userData.Equals(userData2Compare));
			}

			{
				// same object - equal
				UserData_74_Container userData2Compare = new UserData_74_Container(userData.Device, userData.BusType, userData.GetCopyOfBytes());
				Assert.IsTrue(userData.Equals(userData2Compare));
			}

			{
				// different property values - NOT equal                
				UserData_74_Container userData2Compare = new UserData_74_Container((byte)(userData.Device + 1), userData.BusType, userData.GetCopyOfBytes());
				Assert.IsFalse(userData.Equals(userData2Compare));
			}

			{
				// different property values - NOT equal                
				UserData_74_Container userData2Compare = new UserData_74_Container(userData.Device, (byte)(userData.BusType + 1), userData.GetCopyOfBytes());
				Assert.IsFalse(userData.Equals(userData2Compare));
			}

			{
				// different property values - NOT equal                
				UserData_74_Container userData2Compare = new UserData_74_Container(userData.Device, userData.BusType, null);
				Assert.IsFalse(userData.Equals(userData2Compare));
			}
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test02_GetHashCode()
		{
			{
				byte[] bytes = new byte[] { 0x55, 0x66, 0xaa, 0x00, 0xff };
				UserData_74_Container userData = new UserData_74_Container(0x99, (byte)(eBusType.EIBus), bytes);
				int hashCode = userData.GetHashCode();
			}

			{
				byte[] bytes = null;
				UserData_74_Container userData = new UserData_74_Container(0x99, (byte)(eBusType.EIBus), bytes);
				int hashCode = userData.GetHashCode();
			}
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test03_ToString()
		{
			{
				byte[] bytes = new byte[] { 0x55, 0x66, 0xaa, 0x00, 0xff };
				UserData_74_Container userData = new UserData_74_Container(0x99, (byte)(eBusType.EIBus), bytes);
				string stringResult = userData.ToString();
				Assert.IsNotNull(stringResult);
			}

			{
				byte[] bytes = null;
				UserData_74_Container userData = new UserData_74_Container(0x99, (byte)(eBusType.M_Bus), bytes);
				string stringResult = userData.ToString();
				Assert.IsNotNull(stringResult);
			}
		}
	}
}
